#! /usr/bin/python

def main():
    n = 1
    while True:
        if n%1000 == 0:
            print n
        if f(n):
            print n
            return
        n += 1
def f(n):
    l = str(n)
    for i in range(1,7):
        for j in str(n*i):
            if not j in l:
                return False
    return True

if __name__ == '__main__':
    main()
    
